from django.db import models

# Create your models here.


class SectorModel(models.Model):
    title = models.CharField(max_length=20)
    level = models.CharField(max_length=10, null=True, blank=True)
    sector = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True)
    total = models.FloatField(null=True, blank=True)


class UserModel(models.Model):
    sector = models.ForeignKey(SectorModel, on_delete=models.CASCADE)
    name = models.CharField(max_length=20)
    total = models.FloatField()
    state = models.CharField(max_length=5)


class RecordModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE)
    sector = models.ForeignKey(SectorModel, on_delete=models.CASCADE)
    start = models.DateTimeField(auto_now_add=True)
    end = models.DateTimeField(auto_now=True, null=True)
    time = models.DecimalField(max_digits=8, decimal_places=2, null=True)
    total = models.FloatField(null=True)